import 'package:flutter/material.dart';

/// 用于提供全局的 GTNavigatorProvider
class GTNavigatorProvider {

  final GlobalKey<NavigatorState> _navigatorKey = GlobalKey<NavigatorState>(debugLabel: 'GateNav');

  static final GTNavigatorProvider _instance = GTNavigatorProvider._();

  GTNavigatorProvider._();

  /// 赋值给根布局的 materialApp 上
  /// navigatorKey.currentState.pushName('url') 可直接用于跳转
  static GlobalKey<NavigatorState> get navigatorKey => _instance._navigatorKey;

  /// 获取当前的 context
  static BuildContext? get navigatorContext => _instance._navigatorKey.currentState?.context;

  /// 获取当前的 context
  static BuildContext? get currentContext => _instance._navigatorKey.currentState?.context;

  /// 获取当前的 context
  static NavigatorState? get currentState => _instance._navigatorKey.currentState;

  /// 获取当前的 overlay
  static OverlayState? get overlayState => _instance._navigatorKey.currentState?.overlay;

}
